package com.jdiv.samples.scroll;

import com.jdiv.JDiv;
import com.jdiv.JProcess;

public class Simon extends JProcess {
	
	private int vel=5;
	private int run=100;
	private int dir=0;
	private int vSalto=15;
	private int grav=2;
	private int saltando=vSalto;
	private int last_y=0;
	private boolean hold=false;
	private boolean isSaltando=false;;

	public Simon() {
		this.file=Main.fpg_simon;
		this.graph=100;
		this.x=400;
		this.y=165;
		this.ctype=C_SCROLL;
		JDiv.scroll[0].camera=id;
	}

	@Override
	public void begin() {
		// TODO Auto-generated method stub

	}
	
	public void loop(){
		//JDiv.write(0, 100, 10, 0,x+":"+old_x+":"+sX);
		
			if (key(_RIGHT)){
			 if(run>110) run=100; else graph=run;
			 run++;
			 x+=vel;
			 flags=0;
			 dir=0;
	
			 
		}
		
		if (key(_LEFT)){
			 if(run>110) run=100; else graph=run;
			 run++;
			 x-=vel;
			 flags=1;
			 dir=1;
			 
			
			 
		}
		
		if (key(_UP)) y-=vel; 
		if (key(_DOWN)) y+=vel;
		if (key(_S)) vel++; 
		
		if (key(_CONTROL) && !hold){
			hold=true;
			 if (dir>0) flags=1;
			 for (int i=119;i<=125;i++){
				 graph=i;
				 frame();
			 }
			 graph=100;
			 hold=false;
		}
		
		if(key(_SPACE)){
			
			  if (!isSaltando){
				  last_y=y;
				  isSaltando=true;
			  }
		}
	  
		if (isSaltando){
			  saltando-=grav;
	     	  y=y-saltando;
	     	  	if (y==last_y){ isSaltando=false; saltando=vSalto;}
	  
		}
		
	
		
		
	
	}

}
